package co.yixiang.tools.service.impl;

import co.yixiang.tools.service.AliService;
import co.yixiang.tools.utils.OSSUtil;
import com.aliyun.oss.ServiceException;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author
 * @Date2020/7/23 16:36
 * @Version V1.0
 **/
@Service
public class AliServiceImpl implements AliService {

    @Override
    public String upload(MultipartFile file) {
        String pictureURL = "";
        try {
            OSSUtil ossUtil = new OSSUtil();
            pictureURL = ossUtil.upload(file);
        } catch (Exception e) {
            throw new ServiceException();
        }
        return "http://jiayixuan.oss-cn-beijing.aliyuncs.com/"+pictureURL;
    }
}
